package com.kotlin.tsw.goodscenter.presenter

import com.kotlin.tsw.baselibrary.ext.execute
import com.kotlin.tsw.baselibrary.persenter.BasePresenter
import com.kotlin.tsw.baselibrary.rx.BaseSubScriber
import com.kotlin.tsw.goodscenter.data.protocol.Category
import com.kotlin.tsw.goodscenter.presenter.view.CategoryView
import com.kotlin.tsw.goodscenter.service.CategoryService
import javax.inject.Inject

class CategoryPersenter @Inject constructor() : BasePresenter<CategoryView>() {
    @Inject
    lateinit var categporyService: CategoryService

    fun getGetCategory(parentId: Int) {
        /*
        * 业务逻辑
        * */
//        val userService = UserServiceImpl()
        if (!checkNetWork()) {
            mView.onErorr("网络不可用")
            return
        }

        mView.showLoading()
        categporyService.getGetCategory(parentId)
                .execute(object : BaseSubScriber<MutableList<Category>>(mView) {
                    override fun onNext(t: MutableList<Category>) {
                        mView.onGetCatetoryResult(t)
                    }
                }, lifecycleProvider)
    }
}